//package com.zero.account.config;
//
//import org.springframework.cloud.client.ServiceInstance;
//import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
//import org.springframework.cloud.loadbalancer.core.RandomLoadBalancer;
//import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
//import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
//import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//
///**
// * @author zero
// * @ClassName LoadBalancerConfig
// * @Description
// * @Date 2025/5/15 13:37
// */
//@Configuration
//@LoadBalancerClient (name = "account-service", configuration = LoadBalancerConfig.class)
//public class LoadBalancerConfig {
//    /**
//     * 轮询 (Round Robin)	按顺序依次选择服务实例	实例性能相近的均匀分布场景
//     * 随机 (Random)	随机选择服务实例	测试环境或实例完全相同的场景
//     * 加权响应时间 (Weighted)	根据实例的响应时间分配权重，响应越快越容易被选中	实例性能差异较大的场景
//     * 区域感知 (Zone Aware)	优先选择同区域的服务实例	多区域部署场景
//     * 最少活跃数 (Least Active)	选择当前处理请求最少的实例	长连接或处理时间差异
//     * @param environment
//     * @param loadBalancerClientFactory
//     * @return
//     */
//    @Bean
//    ReactorLoadBalancer<ServiceInstance> randomLoadBalancer(
//            Environment environment,
//            LoadBalancerClientFactory loadBalancerClientFactory) {
//        String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
//        return new RandomLoadBalancer(
//                loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class),
//                name);
//    }
//}
